<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>

		<link rel="stylesheet" type="text/css" href="resources/css/style.css">
		<script src="resources/js/comm.js"></script>
		<script type="text/javascript" src="resources/js/imgPreview/CJL.0.1.min.js"></script>
		<script type="text/javascript" src="resources/js/imgPreview/ImagePreviewd.js"></script>
		<script type="text/javascript">
			function checkForm(){
				var name = $("name").value;
				var icon = $("icon").value;
				var remark = $("remark").value;
				var sort = $("sort").value;
				if(name == ""){
					alert("专题名称不能为空");
				}else if(icon != "" && !checkPic(icon)){
					alert("请您选择图片类型\n 必须为PNG");   
				}else if(remark == ""){
					alert("备注不能为空");
				}else if(remark.length>100){
					alert("备注最长为100个字符");   
				}else if(sort == 0){
					alert("排序不能为空");
				}else if(!checkNum(sort)){
					alert("排序应为数字");
				}else{
					loading();
					submitForm("addform");
				}
			}
			</script>

	</head>

	<body onkeydown="if(event.keyCode==27) return false;">
		<jsp:include page="../inc/header.jsp"></jsp:include>
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
			<tr>
				<td height="30" background="resources/images/other/tab_05.gif">
					<table width="100%" border="0" cellspacing="0" cellpadding="0">
						<tr>
							<td width="12" height="30">
								<img src="resources/images/other/tab_03.gif" width="12"
									height="30" />
							</td>
							<td>
								<div class="page_title">
									<img align="middle" src="resources/images/other/tb.gif"
										width="16" height="16" />
									专题信息管理 > 编辑专题
								</div>
							</td>
							<td>
								<div class="button_bar">
									<input value="返回" type="button" id="btn_back" class="common_button"
										onclick="javascript:history.go(-1);loading();">
									<input value="保存" type="button" id="btn_ok" class="common_button" onclick="checkForm();">
									<input value="刷新" type="button" id="btn_re" class="common_button"
										onclick="location='resource.do?method=toUpdate&id=${res.id}';loading();">
								</div>
							</td>
							<td width="16" height="30">
								<img src="resources/images/other/tab_07.gif" width="16"
									height="30" />
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td>
					<table width="100%" border="0" cellspacing="0" cellpadding="0">
						<tr>
							<td width="8" background="resources/images/other/tab_12.gif">
							</td>
							<td>
								<form action="resource.do" method="post" id="addform" enctype="multipart/form-data">
									<input type="hidden" name="method" value="doUpdate">
									<input type="hidden" name="res.id" value="${res.id }">
									<table cellspacing="1" cellpadding="0" class="query_form_table">
										<tr>
											<th>
												专题名称
											</th>
											<td>
												<input class="comm_input" name="res.name" id="name" value="${res.name }" maxlength="50"/>
												<span class="red_star">*</span>
											</td>
										</tr>
										<tr>
											<th>
												专题图标
											</th>
											<td>
												<input class="comm_input" type="file" name="icon" id="icon"/>
												<span class="red_star"></span>
											</td>
										</tr>
										<tr>
											<th>
												备注
											</th>
											<td>
												<textarea class="comm_input" name="res.remark" id="remark" >${res.remark }</textarea>
												<span class="red_star">*</span>
											</td>
										</tr>
										<tr>
											<th>
												排序
											</th>
											<td>
												<input class="comm_input" id="sort"  name="res.sort"  value="${res.sort }"/>
												<span class="red_star">*(已有专题[${count }])</span>
											</td>
										</tr>
										<tr>
											<th>
												图标展示
											</th>
											<td>
												<img id="showimg" width="70" height="70" src="upload/icon/${res.icon }"/>
											</td>
										</tr>
									</table>
								</form>
							</td>
							<td width="8" background="resources/images/other/tab_15.gif">
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td height="35" background="resources/images/other/tab_19.gif">
					<table width="100%" border="0" cellspacing="0" cellpadding="0">
						<tr>
							<td width="12" height="30">
								<img src="resources/images/other/tab_18.gif" width="12"
									height="35" />
							</td>
							<td>
								&nbsp;
							</td>
							<td width="16">
								<img src="resources/images/other/tab_20.gif" width="16"
									height="35" />
							</td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
	</body>
</html>
<script>
var ip = new ImagePreview( $$("icon"), $$("showimg"), {
	 maxWidth: 70, maxHeight: 70
	});
	//ip.img.src = ImagePreview.TRANSPARENT;
	ip.file.onchange = function(){ip.img.src=""; ip.preview(); };
</script>
<jsp:include page="../inc/footer.jsp"></jsp:include>